package Controller;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Controller.AddNewCustomerController;
import Entity.Customer;
import HandleDB.CustomerQuery;
import Communication.Client;
import View.*;



public class UpdateCustomerController {
	
	
	CustomerQuery customerModel;
	UpdateCustomerView customerView;
	Client client;



	
	public UpdateCustomerController(Client client, WorkerMainMenuController workerMainMenuController) {
			
		this.client = client;
		//customerModel = new CustomerQuery(client);
		customerView =  new UpdateCustomerView();
		//customerView.showWindow();
	
			
		customerView.updateCustomerListener(new CustomerInfoListener(workerMainMenuController));
	}
	
	
	class CustomerInfoListener implements ActionListener
	{
		WorkerMainMenuController workerMainController;
		
		
		public CustomerInfoListener(WorkerMainMenuController workerMainController){
			this.workerMainController = workerMainController;
			//customerModel = new CustomerQuery(client);
			customerView.showWindow();
		}
		
		@Override
		public void actionPerformed(ActionEvent event) {
			
			
			if (event.getSource() == customerView.getSearchBtn())
			{
				if (customerModel.isEmpty(customerView.getID()))
						
			
					SystemController.displayErrorMessage("field are Empty");
				
				else
				{ 
					//find the customer
				}
			}
			
			
			else if (event.getSource() == customerView.getBackBtn())
			{
				workerMainController.showWindow();
				customerView.hideWindow();
				customerView.clearFields();
			}
			
			
			
		}
	}
}



